#include "junix.h"

void print_id()
{
	printf("pid:%d\n", getpid());
	printf("sid:%d\n", getsid(getpid()));
	printf("pgid:%d\n", getpgid(getpid()));
}


int pgid;

void sigh(int signo)
{
	if( signo==SIGALRM)
		kill(pgid,SIGSTOP);
}

int main(int argc, char **argv)
{
	pid_t pid=Fork();
	if(!pid)
	{
		printf("child\n");
		print_id();

		if( signal( SIGALRM, sigh) == SIG_ERR)
			err_sys("signal");

//		alarm(19);
		for(;;)
			printf("*");

		exit(0);
	}else{

	printf("\n\nparent\n");
	print_id();
	for(;;)
		printf(".");
	}

	exit(0);
}

